<template>
	<view :class="['page',{'iphoneX':isIphoneX}]">
		<c-header bgColor="bg-white">
			<view class="header" slot="header">
				<view class="title">库存管理</view> 
			</view>
		</c-header> 
		<view class="body">
			<view class="tools-list">
				<view v-if="userInfo.role_id!=24" data-url="/package_kucun/kucun-list/kucun-list" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon1.png" mode="widthFix"></image></view>
					<view class="name">库存列表</view>
				</view>
				<view v-if="userInfo.role_id!=24" data-url="/package_kucun/add-chenpin/add-chenpin?page=add" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon2.png" mode="widthFix"></image></view>
					<view class="name">成品入库</view>
				</view>
				<view v-if="userInfo.role_id!=24" data-url="/package_kucun/add-hecheng/add-hecheng?page=add" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon3.png" mode="widthFix"></image></view>
					<view class="name">合成产品</view>
				</view>
				<view data-url="/package_kucun/chuku/chuku" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon4.png" mode="widthFix"></image></view>
					<view class="name">出库申请</view>
				</view>
				<view v-if="userInfo.role_id!=24" data-url="/package_kucun/cangku-huhuan/cangku-huhuan" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon5.png" mode="widthFix"></image></view>
					<view class="name">仓库互发</view>
				</view>	
				<view data-url="/package_kucun/product-list/product-list?type=1" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon6.png" data-iskucun="1" mode="widthFix"></image></view>
					<view class="name">产品列表</view>
				</view>	
				<view v-if="userInfo.role_id!=24" data-url="/package_kucun/product-list/product-list?type=2" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon7.png" mode="widthFix"></image></view>
					<view class="name">材料列表</view>
				</view>
				<view v-if="userInfo.role_id!=24" data-url="/package_kucun/add-cailiao/add-cailiao?page=add" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon8.png" mode="widthFix"></image></view>
					<view class="name">材料入库</view>
				</view>	
					
			</view>	
			
			<view class="tools-list">
				<view v-if="auth.indexOf(16)!=-1&&userInfo.role_id!=24" data-url="/package_kucun/shenqing-list/shenqing-list?type=list" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/sp_icon1.png" mode="widthFix"></image></view>
					<view class="name">所有申请</view>
				</view>
				<view data-url="/package_kucun/export/export" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/kc_icon9.png" mode="widthFix"></image></view>
					<view class="name">导出数据</view>
				</view>
				<view data-url="/package_kucun/address/address?type=list" data-isopen="1" class="item" @click="jump">
					<view class="icon"><image src="@/static/images/kucun/shdz_icon.png" mode="widthFix"></image></view>
					<view class="name">收货地址</view>
				</view>				
			</view>
		</view>
		
		<c-nav-kucun :switchTab="2"></c-nav-kucun>
		 
		 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLogin:false,
				userInfo:uni.getStorageSync('userInfo'),
				systemInfo:getApp().globalData.systemInfo,
				isIphoneX:getApp().globalData.isIphoneX,
				auth:'' 
			}
		},
		async onLoad(params) { 
			this.getauth();
			this.isLogin=await this.$loginState('check');  
			 
			if(this.isLogin){ 
				 
			}
		},
		onShow() {
			 
		},
		onReachBottom(){
			 
		},
		methods: {
			jump(e){
				let url=e.currentTarget.dataset.url,
				    isOpen=e.currentTarget.dataset.isopen;
				
				if(isOpen==0){
					uni.showToast({
						icon:'loading',
						title:'此功能暂未开放',
						mask:true
					})
					return 
				}
				
				uni.navigateTo({
					url:url
				})
			},
			
			async getauth(){
				let res=await this.$api.user_api.getauth();  
				if(res.data.code==200){    
					this.auth=res.data.data.join(','); 
					console.log(this.auth.indexOf(16))
				}
			}, 
			 
			
		},
		computed:{
			 
		},
		watch:{
			 
		}
		
	}
</script>

<style lang="less">
	.tools-list{
		display: flex;
		flex-wrap: wrap;
		margin: 20rpx;
		padding: 20rpx;
		background: #fff;
		border-radius: 15rpx;
		.item{
			width: 33.3%;
			text-align: center;
			padding: 40rpx 0;
			.icon{
				width: 70rpx;
				height: 70rpx;
				margin: 0 auto 20rpx; 
				image{
					width: 100%;
				}
			}
			.name{
				font-size: 28rpx;
			}
		}
	}
	.row-2{ 
		.item{
			width: 50%;
		}
	}
</style>
